package cn.edu.swu.lms.db;

import cn.edu.swu.lms.entity.Book;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class BookResultsetVisitor implements  ResultsetVisitor<Book>{
    @Override
    public List<Book> visit(ResultSet rs) throws SQLException {
        List<Book>books=new ArrayList<>();
        while (rs.next()){
            Book book=new Book();
            book.setId(rs.getInt("id"));
            book.setName(rs.getString("name"));
            book.setAuthor(rs.getString("price"));
            book.setPrice(rs.getDouble("memo"));
            book.setMemo(rs.getString("publish"));

            books.add(book);
        }
        return books;
    }
}
